home *** CD-ROM | disk | FTP | other *** search
/ PC & Mediji 1998 February / PCM_9802.iso / programi / director / data.z / Behavior Library.cst / 00045_Script_UI Pointer Animate < prev    next >
Text File  |  1997-05-09  |  7KB  |  184 lines

  1. -- Pointer Animate
  2.  
  3.  
  4. -- n state cycling, bounce list used to animate the cursor
  5. -- relies on cast members being contiguous
  6. -- handles StartCursor and EndCursor
  7.  
  8. property RCustomImage, RPointerStyle, RCustomMask
  9. property speed
  10. property enabled  -- if False cursor does not animate
  11. property membermin, membermax
  12. property cycling   -- if not cycling, bouncing
  13. property goingup   -- TRUE if going up through the list,
  14. --                    FALSE if going down
  15. property currentcursor
  16. property numstates
  17.  
  18. property tickcount -- used to keep the clock
  19. property useCustom, startBegin, stopEnd
  20.  
  21. on StartAnimation me
  22.   set the enabled of me = TRUE
  23. end
  24.  
  25. on StopAnimation me
  26.   set the enabled of me = FALSE
  27.   set currentPointer = translate_cursor( me, RpointerStyle, RcustomImage, RcustomMask, useCustom  )
  28.   cursor( currentPointer )
  29.   
  30. end
  31.  
  32.  
  33. on translate_cursor me, setting, image, mask, custom
  34.   if custom then
  35.     set val = [ member image, member mask ]
  36.     return val
  37.   end if
  38.   return setting
  39. end
  40.  
  41.  
  42. on setCursor me, statenum
  43.   if the enabled of me then
  44.     if statenum > the numstates of me then set statenum = the numstates of me
  45.     cursor [ member (statenum + (the membernum of member (the membermin of me)) - 1) ]
  46.   end if
  47. end
  48.  
  49. on setGoingup me, value
  50.   set the goingup of me to value
  51. end
  52.  
  53. on setCycle me, value
  54.   set the cycling of me to value
  55. end
  56.  
  57. on prepareframe me
  58.   if the ticks > the tickcount of me + the speed of me then
  59.     NextState me
  60.     set the tickcount of me = the ticks
  61.   end if
  62. end
  63.  
  64. on NextState me
  65.   if the enabled of me then
  66.     if the cycling of me then
  67.       if the goingup of me then
  68.         set curr = the currentcursor of me  + 1
  69.         if curr > the numstates of me then 
  70.           set curr = 1
  71.         end if
  72.       else -- going down
  73.         set curr = the currentcursor of me  - 1
  74.         if curr < 1 then set curr = the numstates of me
  75.       end if
  76.       
  77.     else -- bouncing
  78.       if the goingup of me then 
  79.         set curr = the currentcursor of me  + 1
  80.         if curr > the numstates of me then
  81.           set curr = curr - 2
  82.           set the goingup of me = FALSE
  83.         end if
  84.       else   --goingUp == FALSE
  85.         set curr = the currentcursor of me  - 1
  86.         if curr < 1 then
  87.           set curr = 2
  88.           set the goingup of me = TRUE
  89.         end if
  90.       end if
  91.     end if
  92.     
  93.     set the currentcursor of me = curr
  94.     setcursor me, curr
  95.   end if
  96. end
  97.  
  98. ---
  99.  
  100. on BeginSprite me
  101.   set the enabled of me = FALSE
  102.   set the numstates of me = (the membermax of me) - (the membermin of me) + 1
  103.   set the tickcount of me = the ticks
  104.   if Cycling = #Repeat then set Cycling = TRUE
  105.   if Cycling = #Reverse then set Cycling = FALSE
  106.   if goingup = true then 
  107.     set goingup= false 
  108.   else set goingup = true 
  109.   
  110.   if startBegin then startAnimation me
  111.   
  112. end
  113.  
  114. on Endsprite me
  115.   if stopEnd then
  116.     set currentPointer = translate_cursor( me, RpointerStyle, RcustomImage, RcustomMask, useCustom  )
  117.     cursor( currentPointer )
  118.   end if
  119.   
  120. end
  121.  
  122. on getPropertyDescriptionList
  123.   
  124.   set p_list = [ ¼
  125.   #startBegin:[ #comment:      "Start Animation on beginSprite:", ¼
  126.                     #format:   #boolean, ¼
  127.                    #default:    FALSE ], ¼
  128.        #stopEnd: [ #comment:   "Restore Cursor on endSprite:", ¼
  129.                     #format:   #boolean, ¼
  130.                    #default:    TRUE ], ¼
  131.   #MemberMin: [ #comment:      "First Image:", ¼
  132.                     #format:   #bitmap, ¼
  133.                    #default:    member 1 ], ¼
  134.      #MemberMax: [ #comment:   "Last Image:", ¼
  135.                     #format:   #bitmap, ¼
  136.                    #default:    member 1 ], ¼
  137.          #Speed: [ #comment:   "Step Rate:", ¼
  138.                     #format:   #integer, ¼
  139.                    #default:    10 ], ¼
  140.        #Cycling: [ #comment:   "Cycle Mode:", ¼
  141.                     #format:   #symbol, ¼
  142.                      #range: [ #Repeat, #Reverse ], ¼
  143.                    #default:   #Repeat ], ¼
  144.        #Goingup: [ #comment:   "Reverse Order:", ¼
  145.                     #format:   #boolean, ¼
  146.                    #default:    FALSE ], ¼
  147.    #RpointerStyle: [ #comment: "Restored Pointer Image:", ¼
  148.                     #format:   #cursor, #default:1], ¼
  149.        #useCustom: [ #comment: "Restore Custom Pointer:", ¼
  150.                     #format:   #boolean, ¼
  151.                    #default:    FALSE ], ¼
  152.   #RcustomImage: [ #comment:   "Restored Custom Image:", ¼
  153.                     #format:   #bitmap, ¼
  154.                    #default:    member 1 ], ¼
  155.     #RcustomMask: [ #comment:   "Restored Custom Mask:", ¼
  156.                     #format:   #bitmap, ¼
  157.                    #default:    member 1 ]  ]
  158.   return p_list    
  159.   return description
  160. end
  161.  
  162. on getBehaviorDescription
  163.   return ¼
  164. "Animates the pointer image using a series of adjacent 1-bit bitmapped cast members.  Drag to any sprite or place in the sript channel." & RETURN & ¼
  165. "PARAMETERS:" & RETURN & ¼
  166. "ò Start on BeginSprite - Turn this option on to start animation when the sprite begins."  & RETURN & ¼
  167. "ò Restore - Turn this option to restore the pointer when the sprite ends."  & RETURN & ¼
  168. "ò First Image - Choose the first cast member in the animation sequence."  & RETURN & ¼
  169. "ò Last Image  - Choose the last cast member in the animation sequence."  & RETURN & ¼
  170. "ò Initial Image - Choose the cast member that should be visible when the animation begins."  & RETURN & ¼
  171. "ò Step Rate - Enter the rate, in ticks ( 1/60 second units ) at which the pointer image should change during animation."  & RETURN & ¼
  172. "ò Cycle Mode - Choose Repeat to show the same sequence every time.  Choose Reverse to alternate between playing the sequence forward and backward." & RETURN & ¼
  173. "ò Reverse Order - Turn this option on to proceed from the last to first image by default."  & RETURN & ¼
  174. "ò Restored Pointer - Choose one of Director's included pointers to be displayed when the sprite ends."  & RETURN & ¼
  175. "ò Use Custom Pointer - Turn this option on to use a cast member instead of an included pointer as the restored pointer image."  & RETURN & ¼
  176. "ò Restored Custom Image  - ( optional ) Choose which cast member to use as the restored pointer image."  & RETURN & ¼
  177. "ò Restored Custom Mask - ( optional ) Choose a cast member to use as a mask image when sprite ends.  "& RETURN & ¼
  178. "MESSAGES:" & RETURN & ¼
  179. "ò StartAnimation - Begin the pointer animation."  & RETURN & ¼
  180. "ò StopAnimation - End the pointer animation."
  181. end
  182.  
  183.  
  184.